//
//  face_sdk.hpp
//  MediaDEmo
//
//  Created by yanpeng on 2023-04-28.
//

#ifndef face_sdk_hpp
#define face_sdk_hpp

#include <string>
#include <jni.h>
#include <opencv2/core/mat.hpp>
#include "android/log.h"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <opencv2/imgproc/types_c.h>
#include "android/bitmap.h"
namespace FaceSDK {
    struct HeadDirect {
        int hor_direct; //水平方向
        int ver_direct; //竖直方向
        float facePitch;
        float faceYaw;
        float faceRoll;

        HeadDirect() {
            hor_direct = 0;
            ver_direct = 0;
            facePitch = 0;
            faceYaw = 0;
            faceRoll = 0;
        }
    };
    struct HeadPoint {
        int x1;
        int y1;
        int x2;
        int y2;
        int x1_old;
        int y1_old;
        int x2_old;
        int y2_old;
        /// 头部区域亮度， 0-255， 值越大代表越亮
        int img_light;
        /// 头部亮度，0：亮度正常；1：亮度太低
        int light_status;
        float face_width_rate;
        int face_distance;
        int x_position;
        int y_position;

        HeadPoint() {
            x1 = 0;
            y1 = 0;
            x2 = 0;
            y2 = 0;
            x1_old = 0;
            y1_old = 0;
            x2_old = 0;
            y2_old = 0;
            img_light = 0;
            light_status = 0;
            face_width_rate = 0.0;
            face_distance = 0;
            x_position = 0;
            y_position = 0;
        }
    };

    struct DetectModel {
        int l_eye_status;
        int r_eye_status;
        int mouse_status;
        FaceSDK::HeadPoint head_position;
        FaceSDK::HeadDirect face_direction;
    };

    /// 检测
/// - Parameters:
///   - image: 图片
///   - face_landmarks 人脸关键点
///   - width: 图片宽度
///   - height: 图片高度
    std::vector<float> detect(JNIEnv *env, cv::Mat image,
                              jdoubleArray _points,
                              int width,
                              int height);

    std::vector<double> detectFinish(JNIEnv *env, jdoubleArray _points);

    std::string detect2(JNIEnv *env, jdoubleArray _points);

    std::vector<float> detect3(JNIEnv *env, jdoubleArray _points, int width, int height);

    cv::Mat convertBitmp2Mat(JNIEnv *env,jobject bitmap);

    jbyteArray convertMat2byteArray(JNIEnv *env,cv::Mat mat);
}
#endif /* face_sdk_h */
